package com.xiaoyu.izf.model;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

@Entity
@Table(name = "yqf_store_stats_day", schema = "izf", catalog = "")
public class YqfStoreStatsDay {
    private int id;
    private String storeId;
    private String storeName;
    private Integer orderAmount;
    private Integer validOrderCount;
    private Integer validOrderAmount;
    private Integer refundCount;
    private Integer refundAmount;
    private Integer commission;
    private Integer income;
    private Integer discountAmount;
    private Double refundProportion;
    private Date recDate;


    private YqfStore yqfStore;
    private String merchantId;
    private String merchantName;

    //流水返佣
    private Double serialCommission;
    @Transient
    public Double getSerialCommission() {
        return serialCommission;
    }
    public void setSerialCommission(Double serialCommission) {
        this.serialCommission = serialCommission;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "store_id")
    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    @Basic
    @Column(name = "store_name")
    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    @Basic
    @Column(name = "order_amount")
    public Integer getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(Integer orderAmount) {
        this.orderAmount = orderAmount;
    }

    @Basic
    @Column(name = "valid_order_count")
    public Integer getValidOrderCount() {
        return validOrderCount;
    }

    public void setValidOrderCount(Integer validOrderCount) {
        this.validOrderCount = validOrderCount;
    }

    @Basic
    @Column(name = "valid_order_amount")
    public Integer getValidOrderAmount() {
        return validOrderAmount;
    }

    public void setValidOrderAmount(Integer validOrderAmount) {
        this.validOrderAmount = validOrderAmount;
    }

    @Basic
    @Column(name = "refund_count")
    public Integer getRefundCount() {
        return refundCount;
    }

    public void setRefundCount(Integer refundCount) {
        this.refundCount = refundCount;
    }

    @Basic
    @Column(name = "refund_amount")
    public Integer getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(Integer refundAmount) {
        this.refundAmount = refundAmount;
    }

    @Basic
    @Column(name = "commission")
    public Integer getCommission() {
        return commission;
    }

    public void setCommission(Integer commission) {
        this.commission = commission;
    }

    @Basic
    @Column(name = "income")
    public Integer getIncome() {
        return income;
    }

    public void setIncome(Integer income) {
        this.income = income;
    }

    @Basic
    @Column(name = "discount_amount")
    public Integer getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(Integer discountAmount) {
        this.discountAmount = discountAmount;
    }

    @Basic
    @Column(name = "refund_proportion")
    public Double getRefundProportion() {
        return refundProportion;
    }

    public void setRefundProportion(Double refundProportion) {
        this.refundProportion = refundProportion;
    }

    @Basic
    @Column(name = "rec_date")
    public Date getRecDate() {
        return recDate;
    }

    public void setRecDate(Date recDate) {
        this.recDate = recDate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        YqfStoreStatsDay that = (YqfStoreStatsDay) o;
        return id == that.id &&
                Objects.equals(storeId, that.storeId) &&
                Objects.equals(storeName, that.storeName) &&
                Objects.equals(orderAmount, that.orderAmount) &&
                Objects.equals(validOrderCount, that.validOrderCount) &&
                Objects.equals(validOrderAmount, that.validOrderAmount) &&
                Objects.equals(refundCount, that.refundCount) &&
                Objects.equals(refundAmount, that.refundAmount) &&
                Objects.equals(commission, that.commission) &&
                Objects.equals(income, that.income) &&
                Objects.equals(discountAmount, that.discountAmount) &&
                Objects.equals(refundProportion, that.refundProportion) &&
                Objects.equals(recDate, that.recDate);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, storeId, storeName, orderAmount, validOrderCount, validOrderAmount, refundCount, refundAmount, commission, income, discountAmount, refundProportion, recDate);
    }

    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, optional = true)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "store_id", referencedColumnName = "id", insertable = false, updatable = false)
    public YqfStore getYqfStore() {
        return yqfStore;
    }

    public void setYqfStore(YqfStore yqfStore) {
        this.yqfStore = yqfStore;
    }

    @Transient
    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    @Transient
    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }
}
